﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage/PBOAMasterPage.master"
  AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="MsgMng_Default" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
  <style>
    /* 提示 */
    #rightContentPlaceHolder .title { font-weight: bold; }
    #rightContentPlaceHolder img { vertical-align: middle; }
    /* 搜索栏 */
    #rightContentPlaceHolder .searchbar { }
    #rightContentPlaceHolder .searchbar .right { }
    #rightContentPlaceHolder .addmessage { text-align: right; }
  </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
  <uc:Navigator Text="消息管理" runat="server" />
  <div class="title">
    请输入填写消息的时间——<img src="../Images/message.gif" /></div>
  <div class="searchbar">
    开始时间：<asp:TextBox ID="tbStartTime" runat="server" Text='<%#new DateTime(DateTime.Now.Year,DateTime.Now.Month,1).ToShortDateString() %>'></asp:TextBox><asp:RegularExpressionValidator
      ID="revStartDate" runat="server" ErrorMessage="格式错误" ControlToValidate="tbStartTime"
      ValidationExpression="(\d{2,4})\/\d{1,2}\/\d{1,2}|(\d{2,4}-\d{1,2}-\d{1,2})" Display="Dynamic"></asp:RegularExpressionValidator>
    <asp:CalendarExtender ID="ceStartTime" runat="server" TargetControlID="tbStartTime"
      Format="yyyy/M/d">
    </asp:CalendarExtender>
    *......结束时间：<asp:TextBox ID="tbEndTime" runat="server" Text='<%# new DateTime(DateTime.Now.Year,DateTime.Now.Month,DateTime.DaysInMonth(DateTime.Now.Year,DateTime.Now.Month)).ToShortDateString() %>'></asp:TextBox>
    <asp:RegularExpressionValidator ID="revEndTime" runat="server" ErrorMessage="格式错误"
      ControlToValidate="tbEndTime" ValidationExpression="(\d{2,4}\/\d{1,2}\/\d{1,2})|(\d{2,4}-\d{1,2}-\d{1,2})"
      Display="Dynamic"></asp:RegularExpressionValidator>
    <asp:CalendarExtender ID="ceEndTime" runat="server" TargetControlID="tbEndTime" Format="yyyy/M/d">
    </asp:CalendarExtender>
    <span class="right">*<asp:RadioButton ID="rbDay" runat="server" GroupName="scope"
      Text="本日" AutoPostBack="True" OnCheckedChanged="rbDay_CheckedChanged" />
      <asp:RadioButton ID="rbWeek" runat="server" GroupName="scope" Text="本周" OnCheckedChanged="rbWeek_CheckedChanged"
        AutoPostBack="True" />
      <asp:RadioButton ID="rbMonth" runat="server" GroupName="scope" Text="本月" Checked="true"
        AutoPostBack="True" OnCheckedChanged="rbMonth_CheckedChanged" />
    </span>
    <asp:ImageButton ID="ibSearch" runat="server" ImageUrl="~/Images/search.gif" />
  </div>
  <div class="addmessage">
    <asp:LinkButton ID="lbAddMessage" runat="server" PostBackUrl="~/MsgMng/AddModify.aspx?act=add"><img src="../Images/file/write.gif" />添加新消息</asp:LinkButton>
  </div>
  <asp:GridView ID="gvMessage" runat="server" Width="100%" AutoGenerateColumns="False"
    BorderColor="#CEDCEC" DataKeyNames="MessTitle,MessContent,IsPublish,MessNo,MessageTypeId"
    OnRowCommand="gvMessage_RowCommand" DataSourceID="odsMessages">
    <Columns>
      <asp:TemplateField HeaderText="消息标题" SortExpression="MessTitle">
        <ItemTemplate>
          <asp:Label ID="Label1" runat="server" Text='<%# CutStr(Eval("MessTitle").ToString(),7) %>'></asp:Label>
        </ItemTemplate>
      </asp:TemplateField>
      <asp:BoundField DataField="MessageTypeId" HeaderText="消息类型" ReadOnly="True" SortExpression="MessageTypeId" />
      <asp:TemplateField HeaderText="消息内容" SortExpression="MessContent">
        <ItemTemplate>
          <a href="#" onclick="window.showModalDialog('showmessage.aspx?id=<%# Eval("MessNo") %>');">
            <%# CutStr(Eval("MessContent").ToString(),20) %></a>
        </ItemTemplate>
      </asp:TemplateField>
      <asp:BoundField DataField="sender" HeaderText="创建人" SortExpression="sender" />
      <asp:TemplateField HeaderText="发送对象" SortExpression="receiver">
        <ItemTemplate>
          <a href="#" onclick="window.showModalDialog('showreceivers.aspx?id=<%# Eval("MessNo") %>');">
            <%# Eval("receiver") %>
          </a>
        </ItemTemplate>
      </asp:TemplateField>
      <asp:BoundField DataField="MessStartTime" HeaderText="开始时间" SortExpression="MessStartTime" />
      <asp:BoundField DataField="MessEndTime" HeaderText="结束时间" SortExpression="MessEndTime" />
      <asp:BoundField DataField="MessCreateTime" HeaderText="创建时间" SortExpression="MessCreateTime" />
      <asp:TemplateField HeaderText="修改" ShowHeader="False">
        <ItemTemplate>
          <asp:ImageButton ID="ibEdit" runat="server" ImageUrl="~/Images/edit.gif" Enabled='<%# !Convert.ToBoolean(Eval("IsPublish")) %>'
            BackColor='<%#System.Drawing.Color.FromName(Convert.ToBoolean(Eval("IsPublish"))? "Gray":"Transparent") %>'
            PostBackUrl='<%# "~/MsgMng/AddModify.aspx?act=modify&id="+Eval("MessNo") %>' />
        </ItemTemplate>
      </asp:TemplateField>
      <asp:TemplateField HeaderText="删除" ShowHeader="False">
        <ItemTemplate>
          <asp:ImageButton ID="ibDelete" runat="server" ImageUrl="~/Images/delete.gif" CommandArgument='<%# Eval("MessNo") %>'
            CommandName="DeleteMsg" OnClientClick="return confirm('真的要删除吗？');" />
        </ItemTemplate>
      </asp:TemplateField>
      <asp:TemplateField HeaderText="发布" SortExpression="IsPublish">
        <ItemTemplate>
          <asp:Button ID="bIsPublish" Text="发布" runat="server" BackColor='<%# System.Drawing.ColorTranslator.FromHtml(!Convert.ToBoolean(Eval("IsPublish"))? "#CEE2F5":"#EBF6FD") %>'
            BorderWidth="1px" BorderColor="Blue" ForeColor='<%# System.Drawing.ColorTranslator.FromHtml(!Convert.ToBoolean(Eval("IsPublish"))? "#3F7B9D":"#A3A2A4") %>'
            Enabled='<%# !Convert.ToBoolean(Eval("IsPublish")) %>' CommandName="ChangePublishState"
            CommandArgument='<%# Eval("MessNo") %>' />
        </ItemTemplate>
      </asp:TemplateField>
      <asp:BoundField DataField="MessNo" HeaderText="MessNo" ReadOnly="True" SortExpression="MessNo"
        Visible="False" />
    </Columns>
    <HeaderStyle BackColor="#58C8FF" ForeColor="White" />
  </asp:GridView>
  <asp:ObjectDataSource ID="odsMessages" runat="server" SelectMethod="GetAllMessages"
    TypeName="PBOffice.BLL.MsgMngBLL">
    <SelectParameters>
      <asp:ControlParameter ControlID="tbStartTime" Name="start" PropertyName="Text" Type="DateTime" />
      <asp:ControlParameter ControlID="tbEndTime" Name="end" PropertyName="Text" Type="DateTime" />
      <asp:SessionParameter DefaultValue="" Name="user" SessionField="userManage" 
        Type="Object" />
      <asp:Parameter DefaultValue="true" Name="getAll" Type="Boolean" />
    </SelectParameters>
  </asp:ObjectDataSource>
</asp:Content>
